import pandas as pd
url = "https://raw.githubusercontent.com/MicrosoftDocs/mslearn-introduction-to-machine-learning/main/Data/ml-basics/penguins.csv"
df = pd.read_csv(url)
print(df.head())
import matplotlib.pyplot as plt
df['Species'].value_counts().plot(kind='bar')
plt.show()
import seaborn as sns
sns.boxplot(x='Species', y='FlipperLength', data=df)
plt.show()
sns.boxplot(x='Species', y='CulmenLength', data=df)
plt.show()
sns.boxplot(x='Species', y='CulmenDepth', data=df)
plt.show()
print(df.isnull().sum())
df = df.dropna()
features = df[['CulmenLength', 'CulmenDepth', 'FlipperLength']]
labels = df['Species']
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(features, labels, test_size=0.3, random_state=42)
from sklearn.linear_model import LogisticRegression
model = LogisticRegression(multi_class='multinomial', solver='lbfgs')
model.fit(X_train, y_train)
from sklearn.metrics import accuracy_score
y_pred = model.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print(f'Accuracy: {accuracy:.2f}')

